//
//  DDMusicProgressView.m
//  DDMusic
//
//  Created by rimi on 16/11/8.
//  Copyright © 2016年 FengBaoFamily. All rights reserved.
//
/*****************这是音乐播放进度条********************/
#import "DDMusicProgressView.h"
#import "UILabel+DDUILabelCategory.h"
#import "DDPublicMacro.h"
@implementation DDMusicProgressView
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self layoutUI:frame];

    }
    return self;
    
    
}
#pragma mark UI布局
- (void)layoutUI:(CGRect)frame{
//currentTimeLabel
    self.currentTimeLabel = [UILabel dd_CreatLabelWithTitle:@"00:00" font:14 TitleColor:[UIColor whiteColor] TextAlignment:NSTextAlignmentCenter];
    [self addSubview:self.currentTimeLabel];
//musicSider
    self.musicSider = [[UISlider alloc]init];
    [self addSubview:self.musicSider];
//musicTimeLabel
    self.musicTimeLabel = [UILabel dd_CreatLabelWithTitle:@"00:00" font:14 TitleColor:[UIColor whiteColor] TextAlignment:NSTextAlignmentCenter];
    [self addSubview:self.musicTimeLabel];
    
    
    
    
    
}
- (void)layoutSubviews{
    if (self.progressStyle == MusicProgressDefaultStyle) {
        self.currentTimeLabel.frame = CGRectMake(0, 0, 40,20 );
        self.musicSider.frame = CGRectMake(self.currentTimeLabel.frame.origin.x+self.currentTimeLabel.frame.size.width+4, self.currentTimeLabel.frame.origin.y+5, self.frame.size.width-(self.currentTimeLabel.frame.size.width+8)*2-8, 10);
        self.musicTimeLabel.frame = CGRectMake(self.musicSider.frame.size.width+self.musicSider.frame.origin.x+4, 0, 40, 20);
        self.musicTimeLabel.frame = CGRectMake(self.musicSider.frame.size.width+self.musicSider.frame.origin.x+4, 0, 40, 20);
        

    }else{
        self.currentTimeLabel.hidden = YES;
        self.musicTimeLabel.hidden = YES;
        self.musicSider.frame = CGRectMake(0, 0, self.frame.size.width, 10);
    
    }
    
}
#pragma mark 更新UI样式
- (void)refreshUI:(UIImage*)thumbImage minimumTrackTintColor:(UIColor*)minimumTrackTintColor maximumTrackTintColor:(UIColor*)maximumTrackTintColor{
    [self.musicSider setThumbImage:thumbImage forState:(UIControlStateNormal)];
    self.musicSider.minimumTrackTintColor = minimumTrackTintColor;
    self.musicSider.maximumTrackTintColor = maximumTrackTintColor;
    

}

@end

